<template>
  <div class="album-rate-list">
    <tag-content-header search refresh @toolFun="toolFun" :settingData="columns">
      <template #title>
        <span>评价列表</span>
      </template>
    </tag-content-header>
    <tag-table
      ref="table"
      @refresh="getList"
      :data="dataList"
      :loading="loading"
      :columns="columns"
      :params="params"
      :total="totalSize"
    >
      <template #userNnm="{ scope }">
        {{ $name(scope.row, 'userNnm', 'userNm') }}
      </template>
      <template #infoAcrc="{ scope }">
        <div class="operation-button-box">{{ scope.row.infoAcrc }} <i class="el-icon-star-on el-star"></i></div>
      </template>
      <template #dataAcrc="{ scope }">
        <div class="operation-button-box">{{ scope.row.dataAcrc }} <i class="el-icon-star-on el-star"></i></div>
      </template>
      <template #dataTmln="{ scope }">
        <div class="operation-button-box">{{ scope.row.dataTmln }} <i class="el-icon-star-on el-star"></i></div>
      </template>
    </tag-table>
  </div>
</template>

<script>
export default {
  props: {
    assetId: {
      type: String,
      required: true,
      default: ''
    }
  },
  data() {
    return {
      loading: false,
      dataList: [],
      belongAlbumIds: [],
      columns: [
        {
          show: true,
          label: '评价人',
          prop: 'userNnm',
          search: true,
          searchKey: '',
          align: 'center'
        },
        {
          show: true,
          label: '评价时间',
          prop: 'cmntTm',
          align: 'center'
        },
        {
          show: true,
          label: '信息准确性评分',
          prop: 'infoAcrc',
          align: 'center'
        },
        {
          show: true,
          label: '数据准确性评分',
          prop: 'dataAcrc',
          align: 'center'
        },
        {
          show: true,
          label: '数据时效性评分',
          prop: 'dataTmln',
          align: 'center'
        },
        {
          show: true,
          label: '一句话简评',
          prop: 'cmntPhrase',
          search: true,
          searchKey: '',
          align: 'center'
        }
      ],
      params: {
        ascs: [],
        descs: [],
        currentPageNum: 1,
        pageSize: 10,
        queryParams: {},
        descPriority: false
      },
      totalSize: 0
    }
  },
  methods: {
    getInfo() {
      this.getList()
    },
    getList() {
      this.loading = true
      this.params.queryParams.assetId = this.assetId
      this.$ajax({
        url: this.$ajax.setUrl('index/supermarket/cmntList'),
        method: 'get',
        params: this.$ajax.setParams(this.params)
      }).then(({ data }) => {
        if (data && data.code === '0') {
          if (data.data.currentPageNum === this.params.currentPageNum) {
            this.dataList = data.data.records
            this.totalSize = data.data.totalSize
          }
        } else {
          this.$message.error(data.data || data.msg)
        }
        this.loading = false
      })
    },
    toolFun(operation) {
      switch (operation) {
        case 'search':
          // 搜索动作
          this.$refs['table'].searchToggle()
          break
        case 'refresh':
          // 刷新动作
          this.getList()
          break
      }
    }
  }
}
</script>

<style lang="scss">
.album-rate-list {
  padding-top: 20px;
  .el-star {
    font-size: 20px;
    color: #f9c323;
    margin-top: -2px;
  }
}
</style>
